﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VideoIndexViewModels>" %>
<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Site.ViewModels" %>
<%if (Model.Videos != null && Model.Videos.Count > 0)
     {
         var first = Model.Videos[0]; %> 
<div class="bor_cor content mar_t" style="overflow:hidden;">
    <div class="heading_bar">
        <div class="heading_bar_tit">
            <a href="/video/category/<%=Model.Category.ID %>"><%=Html.Encode(Model.Category.Name) %></a>
        </div>    
    </div>
    <div class="xtt"><a href="/video/category/<%=Model.Category.ID %>">Xem tất cả</a></div>
    <div class="heading_bar_line"></div>
    <div class="tt_pad ">
        <div class="tt_img">
            <a href="/video/details/<%=first.ID %>/<%=Html.ToUrlFriendly(first.Name)%>">
                <% string imgPath = !string.IsNullOrEmpty(first.ImagePath) ? ChoViet.Lib.Common.Utils.GenThumbnail(first.ID, 200, 138, first.ImagePath, Model.VideoImagePath, Model.VideoImageUrl) : ChoViet.Lib.Common.Globals.DefaultLogo; %>
                <img src="<%=imgPath %>" title="<%=first.Name %>" alt="<%=first.Name %>" class="bor_img" width="200" height="138" style="overflow:hidden"/>
            </a>
        </div>        
        <div class="tt_cnt" style="max-height:138px; overflow:hidden">
            <h2><a href="/video/details/<%=first.ID %>/<%=Html.ToUrlFriendly(first.Name)%>" class="link_org"><%=Html.Encode(first.Name) %></a></h2>
            <div class="datetime"><%=first.AddDate != null ? (ChoViet.Lib.Common.Utils.ToDayOfWeekLabel(first.AddDate.Value) +", "+ string.Format( "{0:dd/MM/yyyy, hh:mm tt}",first.AddDate)) : string.Empty%></div>
            <div>
                <%= first.Description%>
            </div>
        </div>
    
        <div class="clear"></div>
        <div style="display:block; overflow:hidden">       
            <div class="tt_2col_l pad">        
                <%var total = Model.Videos.Count - 1;
                  int totaRight = total / 2;
                  int totalLeft = total -totaRight;
                  if (totalLeft > 0)
                { %>
       	          <%for (int i = 1; i < totalLeft+1; i++)
                    {
                        string imgPath1 = !string.IsNullOrEmpty(Model.Videos[i].ImagePath) ? ChoViet.Lib.Common.Utils.GenThumbnail(Model.Videos[i].ID, 70, 56, Model.Videos[i].ImagePath, Model.VideoImagePath, Model.VideoImageUrl) : ChoViet.Lib.Common.Globals.DefaultLogo;
                     %>
       	                <div class="tt_2col_img">
       	                    <a href="/video/details/<%=Model.Videos[i].ID %>/<%=Html.ToUrlFriendly(Model.Videos[i].Name)%>">
                                <img class="bor_img" src="<%=imgPath1 %>" title="<%=Model.Videos[i].Name %>" alt="<%=Model.Videos[i].Name %>" width="70" height="56" />
                            </a>
       	                </div>
       	                <div class="tt_2col_cnt">
       	                    <a href="/video/details/<%=Model.Videos[i].ID %>/<%=Html.ToUrlFriendly(Model.Videos[i].Name)%>"><%=Html.Encode(Model.Videos[i].Name)%></a>
       	                </div>
       	                <div class="clear"></div>            
                   <%} %>
              <%} %>
            </div>
            <div class="tt_2col_r pad">
                <%if (totaRight > 0)
                { %>
       	          <%for (int i = 1 + totalLeft; i < Model.Videos.Count; i++)
                    {
                        string imgPath1 = !string.IsNullOrEmpty(Model.Videos[i].ImagePath) ? ChoViet.Lib.Common.Utils.GenThumbnail(Model.Videos[i].ID, 70, 56, Model.Videos[i].ImagePath, Model.VideoImagePath, Model.VideoImageUrl) : ChoViet.Lib.Common.Globals.DefaultLogo;
                     %>
       	                <div class="tt_2col_img">
       	                    <a href="/video/details/<%=Model.Videos[i].ID %>">
                                <img class="bor_img" src="<%=imgPath1 %>" title="<%=Model.Videos[i].Name %>" alt="<%=Model.Videos[i].Name %>" width="70" height="56" />
                            </a>
       	                </div>
       	                <div class="tt_2col_cnt">
       	                    <a href="/video/details/<%=Model.Videos[i].ID %>"><%=Html.Encode(Model.Videos[i].Name)%></a>
       	                </div>
       	                <div class="clear"></div>                    
                   <%} %>
              <%} %>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<%} %>
<div class="clear"></div>
